// import the fs module to operate the files
const fs = require('fs');

/**
 * fs.writeFile(file, data[, options], callback) usage: write the specific content into the file
 *      1. file: filename or file descriptor
 *      2. data: the buffer to read or the contents to write directly
 *      3. options: please refer to official API document
 *      4. callback
 *             a. err:  null if the writing operator hasn't happened exceptions.
 */

fs.writeFile("../resources/welcomenode.txt", 
            "Welcome to Node.js!", 
            err => {
                if(err) console.log("Happening: " + err.message);

                console.log(data + " have written into the target file");
            });